﻿@model BG.Web.ViewModels.RegisterModel

<script type="text/javascript">


    $(document).ready(function () {

        $("#loading").hide();


        setTimeout(function () {
            $('#checkUser').click(function (e) {

                $("#loading").show();

                $.ajax({
                    url: "/Account/ValidateUser?text=" + $('.User-Name').val(),
                    type: "GET",
                    async: false,
                    cache: false,

                    beforeSend: function () {
                        $("#loading").show()
                    },
                    complete: function () {
                        $("#loading").hide();
                    },
                    success: function (msg) {
                        $('#IsUserValid').val(msg.isvalid);
                        $('#showdata').html("<b>" + msg.result + "</b>");
                    }
                });

            });
        }, 2000); //wait 1 sec



        setTimeout(function () {
            $('#register').click(function (e) {

                $("#loading").show();

                $.ajax({
                    url: "/Account/Register2?username=" + $('.User-Name').val() + "&email=" + $('.E-mail').val(),
                    type: "GET",
                    async: false,
                    cache: false,

                    beforeSend: function () {
                        $("#loading").show()
                    },
                    complete: function () {
                        $("#loading").hide();
                    },
                    success: function (msg) {
                        $('#returnpass').html("<b>" + msg.pass + "</b>");
                    }
                });

            });
        }, 2000); //wait 1 sec
    });
   
</script>
 
@using (Html.BeginForm("Register", "Account", FormMethod.Post, new { @class = "clearfix" }))
{
    <h1>Not a member yet? Sign Up!</h1>				
	<label class="grey" for="signup">Username:</label>
    <input type="hidden" id="IsUserValid" name="IsUserValid" />
   
    <input type="text" id="UserName" name="UserName" class="User-Name" />
    <img id="checkUser" src="@Url.Content("~/Images/21.png")" alt="Checker" />
    <img id="loading" src="@Url.Content("~/Images/loading2.gif")" alt="Processing" />
    <div id="showdata"></div>
   @* @Html.TextBoxFor(m => m.UserName, new { @class = "field" })*@

    
    
	<label class="grey" for="email">Email:</label>
    <input type="text" id="Email" name="Email" class="E-mail" />
	<label id="returnpass">A password will be e-mailed to you.</label>
    <input type="button" value="register"  id="register" />
	@*<input type="submit" name="submit" value="Register" class="button_01" />*@
        
}